﻿import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.2
import QtQuick.Controls 2.12
import QtMultimedia 5.14
import ".."

ApplicationWindow {
    id: preferenceSettings
    width: 600*dp
    height: 960*dp
    minimumWidth: 600*dp
    minimumHeight: 960*dp
    title: "状态获取"
    property var nums: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32]
    property var bhs: ["S1","S2","S3","S4","S5","S6","S7","S8","S9","S10","S11","S12","S13","S14","S15","S16","S17",
        "S18","S19","S20","S21","S22","S23","S24","S25","S26","S27","S28","S29","S30","S31","S32"]
    property var infos: ["","","","主气路传感器接收端","送靶气缸传感器接靶到位","送靶气缸传感器送靶到位","溶靶瓶在位传感器",
    "水冷机开关H3","水冷机报警H2","主气路传感器接收端","送靶气缸传感器接靶到位","送靶气缸传感器送靶到位","进料气缸传感器完全抬起",
    "进料气缸传感器完全落下","主气路传感器接收端","","","夹爪气缸传感器完全释放","夹爪气缸传感器完全夹紧",
    "挡料气缸传感器靶材停止","挡料气缸传感器靶材通过","Z轴气缸传感器拧盖传感器","Z轴气缸传感器完全落下","Z轴气缸传感器完全抬起",
    "","20m气路卡滞传感器2","20m气路卡滞传感器1","液位传感器","","","",""]
    property var statesv: ["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""]
    Config{
        id: config
    }
    Connections{
        target: CSignal
        onInfolist:{
            statesv=value
        }
    }
    readonly property real dp: config.dp
    CustomButton{
        x:parent.width-280*dp
        y:20*dp
        title: "单次读取"
        defaultMode1: true
        onReleased: {
            CMaintenance.getStateInfo()
        }
    }
    CustomButton{
        x:parent.width-140*dp
        y:20*dp
        title: "连续读取"
        defaultMode1: true
        onReleased: {
            if(title==="连续读取"){
                CMaintenance.getStateInfos(title)
                title="停止读取"
            }else{
                CMaintenance.getStateInfos(title)
                title="连续读取"
            }
        }
    }
    Rectangle{
        x:20*dp
        y:80*dp
        height: 40*dp
        width: parent.width-40*dp
        color: "#F2F2F2"
        Text {
            x:0*dp
            y:10*dp
            width: parent.width*0.15
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            text: qsTr("序号")
            font.pixelSize: config.fontsize
        }
        Text {
            x:parent.width*0.15
            y:10*dp
            width: parent.width*0.15
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            text: "编号"
            font.pixelSize: config.fontsize
        }
        Text {
            x:parent.width*0.3
            y:10*dp
            width: parent.width*0.55
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            text: "信息"
            font.pixelSize: config.fontsize
        }
        Text {
            x:parent.width*0.85
            y:10*dp
            width: parent.width*0.15
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            text: qsTr("状态")
            font.pixelSize: config.fontsize
        }
    }
    Rectangle{
        x:20*dp
        y:120*dp
        width: parent.width-40*dp
        height: parent.height-130*dp
        ScrollView {
            x:0*dp
            y:0*dp
            width: parent.width
            height: parent.height
            clip: true
            Column{
                id: stateinfo
                width: parent.width
                spacing: 1*dp
                Repeater{
                    id:infomod
                    model: statesv.length
                    delegate: Item {
                        x:0*dp
                        width: preferenceSettings.width-40*dp
                        height: 30*dp
                        StatePOPList{
                            xh:nums[index]
                            bh:bhs[index]
                            infov: infos[index]
                            statev: statesv[index]
                        }
                    }
                }
            }
        }
    }

}
